1. Field of the Invention
The present invention relates to a technique, in a system wherein a plurality of host devices share an external storage device, for maintaining coherency between the external storage device and a cache included in each of the host devices.
2. Description of the Related Art
To balance the access time of a memory and magnetic disk unit, a disk cache is prepared for retaining, in the memory, a portion of data stored on a disk. For example, in response to an instruction for reading data on the disk, if the corresponding data exists in the disk cache, a processor of a system having the disk cache reads out the data from the disk cache, without reading the data from the disk, thereby improving the average access time.
A disk is shared by a plurality of host devices, and a disk cache may be included in each of the host devices. Unexamined Japanese Patent Application KOKAI Publications Nos. S61-173355 and S64-76345 disclose a technique for including a disk cache in each of a plurality of host devices that share a disk. In the technique of the former publication, data stored in the disk cache included in each of the host devices is to be read only, not updated, and hence no problem should occur in the coherency between each of the disk caches and the shared disk.
In the technique of the latter publication, data is written into the disk cache of each of the host devices, and the following control processing is performed for maintaining the coherency between each of the disk caches and the shared disk. In the case where one host device is to write data in its disk cache, the host device informs another host device about the writing of data, and reserves the shared disk. At the time the one host device writes data into the disk cache therein, the one host device writes the data into the shared disk, and erases the data of the same block retained in the disk cache of the other host devices.
In this conventional technique, in the case where data is written sequentially in successive areas of a disk cache in one host device, the above-described control processing for maintaining the coherency is required, each time the data is written to one address. In this conventional technique, the overhead of the process for maintaining the coherency is large, and hence there is a problem that the average access time for accessing a file is quite long.
The present invention has been made in consideration of the above. It is accordingly an object of the present invention to provide a technique for reducing an average access time for each of a plurality of host devices to access data, while maintaining coherency between a cache included in each of the host devices and an external storage device which is shared by the plurality of host devices.
In order to achieve the above object, according to the first aspect of the present invention, there is provided an external-storage sharing system including a plurality of host devices and an external storage device which is connected to each of the host devices, and each of the host devices has a cache retaining a portion of data stored in the external storage device.
Furthermore, in a case where data is written in its own cache, each of the host devices informs any of the other host devices and the external storage device that the data is to be written and informs them about information representing a block including the data to be written. In a case where reading or writing data of the block of any one of the plurality of host devices, each of the host devices requess the external storage device to transmit the data of the block, and after the data of the block is written back into the external storage device in response to this request, reads or writes the data. In a case where transmission of data is requested from any one of the host devices, the external storage device writes back the data of the block from the cache of one of the host devices having informed that the data has been written and transmits the data of the block to the cache of one of the host devices having requested the transmission of the data, after the data of the block is written back into the external storage device.
In the above external-storage sharing system, even if data is written in the cache of one of the host devices, the data is written in the disk device only when the data of a corresponding block is required by another one of the host devices. In the case where data is written to successive addresses in one host device, there is no need to write the latest data in the external storage device.
In the case where the data of the block is required by the another one of the host devices, the data is read or written after the data stored in the external storage device is updated. Hence, there should be no coherency problem between the external storage device and the cache of each of the host devices. That is, in the external-storage sharing system of this invention, while maintaining the coherency therebetween, a reduction in the average access time can be realized.
In the external-storage sharing system according to the first aspect of the present invention, each of the host devices may also erase the data of the block included in its own cache, in a case where any of the other host devices informs each of the host devices to write the data of the block.
In order to achieve the above object, according to the second aspect of the present invention, there is provided an external-storage sharing system including a plurality of host devices and an external storage device, which is connected to each of the host devices and stores data in a unit of blocks. Each of the plurality of host devices includes a cache retaining data of a part of entire blocks included in the external storage device, a first memory storing a first program for reading and writing data stored in the external storage device and a second program for maintaining coherency between the external storage device and the cache of each of the host devices, and a processor for executing the first and second programs stored in the first memory.
The second program, in a case where data to be written in accordance with the first program is retained in the cache included in a corresponding one of the host devices, writes the data to be written in the cache in the corresponding one of the host devices, and informing any other host device and the external storage device that writing of the data is performed. In addition, the second program also requests the external storage device to transmit the data of the block, in a case where data of a block including data that is informed from any other host device in accordance with the first program is to be read. Finally, the second program reads data from the cache included in the corresponding one of the host devices, after storing the data of the block which is transmitted from the external storage device in response to the request for transmission of the data.
The external storage device includes a second memory storing a third program for maintaining coherency between the external storage device and the cache of each of the host devices, and a processor executing the third program stored in the second memory. The third program manages information representing whether data of each block which is stored in the external storage device is the latest data, in accordance with the information for writing data and which is sent from each of the host devices; and transmits the latest data as requested data of a corresponding block to a corresponding host device which has sent the request, in response to a request for transmission of data from any one of the host devices.
In the external-storage sharing system according to the second aspect of the present invention, the second program may also erase a block including the data from the cache included in a corresponding host device, in a case where any other one of the plurality of host devices informs that writing of data is performed, and the request for transmission of data, in case of data reading, may request the external device to transmit the data of the block, in a case where data to be read is erased from the cache included in the corresponding host device.
In the external-storage sharing system according to the second aspect, the second program may also request the external storage device to transmit the data of the block in a case where data of a block is to be written including data which is informed from any other host device in accordance with the first program, and write data to be written into the cache included in a corresponding host device, after storing the data of the block which is transmitted from the external storage device in response to the requesting of the transmission of the data, in the cache in the corresponding one of the host devices.
In the external-storage sharing system according to the second aspect, the second program may also erase a block including the data from the cache included in the corresponding host device, in a case where any other host device informs that writing of data is performed. In this case, the request for transmission of data may request the external storage device to transmit the data of the block, in a case where data to be written has been erased from the cache of the corresponding one of the plurality of host devices.
In the external-storage sharing system according to the second aspect, the third program may also determine whether data of a corresponding block which is retained in the external storage device is latest data, in a case where transmission of data is requested from one of the plurality of host devices, request one of the host devices which has a cache retaining the latest data to transmit the data of the block, in a case where it is determined that the data is not the latest data, and store in the external storage device the data of the block that is transmitted from the host device having requested the transmission of the data in response to the requesting of transmission of the data.
In this case, transmitting data to the host device having requested the transmission of the data may be executed upon transmission of the data of the block from the host device having requested the transmission, and the second program may also transmit the data of a corresponding block which is retained in the cache included in the corresponding one of the plurality of host devices, in a case where transmission of data is requested from the external storage device in accordance with the third program.
In the external-storage sharing system according to the second aspect, the external storage device and the plurality of host devices may be connected to each other through a network, and may transmit and receive data to and from each other through a network.
In the external-storage sharing system according to the second aspect, the external storage device may be a hard disk device, for example.
In the external-storage sharing system according to the second aspect, the cache may be prepared in a portion of the first memory included in each of the host devices.
In order to achieve the above object according to the third aspect of the present invention, there is provided a host device which shares an external storage device storing data in a unit of blocks with at least one host device. This host device includes a cache which retains data of a part of entire blocks included in the external storage device; a memory which stores a first program for reading and writing data stored in the external storage device and a second program for maintaining coherency between the external storage device and the host device; and a processor which executes the first and second programs stored in the memory. The second program writes data to be written in the cache included in the processor, in a case where data to be written in accordance with the first program is retained in the cache included in the memory of the host device; and informs at least one host device and the external storage device that the writing of the data is performed. It also requests the external storage device to transmit the data of the block, in a case where data of a block including data is to be read, which is informed from the one host device in accordance with the first program , and reads data to be read out from the cache included in the memory of the host device after storing the data of the block which is transmitted from the external storage device in response to the request for transmission of the data.
In the host device, the second program may further include a step of erasing a block including the written data from the cache included in the memory of the host device in a case where the at least one host device informs that writing of data is performed. In this case, the request for the transmission of data may request the external storage device to transmit data of a corresponding block, in a case where the data to be read is erased from the cache included in the memory of the host device.
In the host device, the second program may also request the external storage device to transmit the data of the block in a case where data of a block including data that is informed from the one host device in accordance with the first program is to be written; and write data to be written in the cache included in the memory of the host device after storing in the cache the data of the block transmitted from the external storage device in response to the request for the transmission of the data.
In the host device, the second program may also erase a block including the data from the cache included in the memory of the host device, in a case where the one host device informs that writing of data is performed. In this case, the request for the transmission of data requests the external storage device to transmit the data of the block in a case where data to be written has been erased from the cache included in the memory of the host device.
In order to achieve the above object, according to the fourth aspect of the present invention, there is provided a method for use in a system for sharing an external storage device between a plurality of host devices each having a cache for maintaining coherency between the external storage device and the cache included in each of the host devices. The method includes informing the external storage device and any other one of the host devices that the data is to be written in the cache and about information regarding a block including the data to be written, in a case where to write data in the cache of an arbitrary one of the plurality of host devices; requesting, in one of the plurality of host devices the external storage device to transmit the data of the block in a case where to read or write data of the block which is written and has already been informed from the arbitrary one of the plurality of host devices; writing back in the external storage device the data of the block from the cache of the arbitrary one of the host devices having informed about the writing of data in a case where transmission of data is requested, reading or writing the data in the any other one of the plurality of host devices, after the data of the block is written back into the external storage device; and transmitting the data of the block from the external storage device into the cache of the other one of the host devices having requested the transmission of the data, after the data of the block has been written back thereinto.
The above-described method may further include erasing the data of the block inside the cache included in the arbitrary one of the plurality of host devices, in a case where the information is sent by any other of the host devices.
In order to achieve the above object, according to the fifth aspect of the present invention, there is provided a computer readable recording medium which records a program executed in each of a plurality of host devices so as to maintain coherency between a cache included in each of host devices and an external storage device. The program writes data to be written into the cache included in a corresponding one of the host devices and informs any other of the host devices that the writing of the data is performed, in a case where the data to be written is retained in the cache included in the corresponding one of the plurality of host devices, The program also requests the external storage device to transmit the data of the block in a case where data of a block including data which is written and informed by the other one of the host devices to be transmitted, and reads data to be read from the cache included in the corresponding one of the plurality of host devices, after storing the data of the block transmitted from the external storage device in response to the request for transmission of the data.
In the recording medium, the program may also include erase the block of the data from the cache of the corresponding one of the plurality of host devices in a case where the other one of the host devices informs that the writing of data is performed. In this case, the request for transmission of data may request the external storage device to transmit data of a block, in a case where the data to be read has been erased from the cache included in the corresponding one of the plurality of host devices.
In the recording medium, the program may also request the external storage device to transmit the data of the block in a case where data of a block including data which is written and informed by the other one of the host devices is to be transmitted, and write data to be written in the cache of the corresponding one of the plurality of host devices, after storing, into the cache of the corresponding one of the plurality of host devices, the data of the block transmitted from the external storage device in response to the requesting of transmission of the data.
In the recording medium, the program may also erase the data of the block from the cache of the corresponding host device, in a case where the other one of the host devices informs that writing of data is performed. In this case, the request for the transmission of data requests the external storage device to transmit data of a block, in a case where the data to be written has been erased from the cache of the corresponding one of the plurality of host devices.